﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MahdieLabDataBaseModel;

public partial class Guest_Paper : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        using (DefaultEntityConnection connection = new DefaultEntityConnection())
        {
            foreach (Paper paper in connection.Papers)
            {                
                UserControl paperUserControl = (UserControl)LoadControl("~/UserControl/PaperUserControl.ascx");
                Type paperUserControlType = paperUserControl.GetType();

                System.Reflection.PropertyInfo paperUserControlHeadLine = paperUserControlType.GetProperty("HeadLine");
                System.Reflection.PropertyInfo paperUserControlDescription = paperUserControlType.GetProperty("Description");
                System.Reflection.PropertyInfo paperUserControlPicture = paperUserControlType.GetProperty("Picture");
                System.Reflection.PropertyInfo paperUserControlFile = paperUserControlType.GetProperty("File");

                paperUserControlHeadLine.SetValue(paperUserControl,paper.PaperTitle,null);
                paperUserControlDescription.SetValue(paperUserControl, paper.Description, null);
                paperUserControlPicture.SetValue(paperUserControl, string.Format("~/Images/Paper/{0}", paper.ImageUrl), null);
                paperUserControlFile.SetValue(paperUserControl, string.Format("~/Files/Paper/{0}", paper.FileUrl), null);


                Info.Controls.Add(paperUserControl);
            }
        }               
    }
}